package com.utils.exception;

import com.utils.ResultCodeEnum;


public class CMSException extends RuntimeException {
    private Integer code;

    /**
     * 构造函数
     * @param code 状态码
     * @param message 消息
     */
    public CMSException(Integer code, String message) {
        super(message);
        this.code = code;
    }

    /**
     * 构造函数
     * @param message
     */
    public CMSException(String message) {
        super(message);
    }

    /**
     * 构造函数
     * @param code
     */
    public CMSException(Integer code) {
        this.code = code;
    }

    /**
     * 构造函数
     * @param resultCodeEnum 返回实体状态码
     */
    public CMSException(ResultCodeEnum resultCodeEnum) {
        super(resultCodeEnum.getMessage());
        this.code = resultCodeEnum.getCode();
    }



    /**
     *
     * @param message
     * @param cause 抛出异常类
     * @param code
     */
    public CMSException(String message, Throwable cause, Integer code) {
        super(message, cause);
        this.code = code;
    }

    /**
     *
     * @param cause
     * @param code
     */
    public CMSException(Throwable cause, Integer code) {
        super(cause);
        this.code = code;
    }

    /**
     *
     * @param message
     * @param cause 抛出异常类
     * @param enableSuppression
     * @param writableStackTrace 是否打印异常信息
     * @param code
     */
    public CMSException(String message, Throwable cause, boolean enableSuppression,
                        boolean writableStackTrace, Integer code) {
        super(message, cause, enableSuppression, writableStackTrace);
        this.code = code;
    }






    public Integer getCode() {
        return code;
    }
    public void setCode(Integer code) {
        this.code = code;
    }
    @Override
    public String toString() {
        return "CMSException{" + "code=" + code + ", message=" + this.getMessage() + '}';
    }

}